package com.woniu.user;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@MapperScan(basePackages = "com.woniu.user.dao")
public class WoniuYogaUserApplication {

    public static void main(String[] args) {
        SpringApplication.run(WoniuYogaUserApplication.class, args);
    }

    @Bean// 将分页插件拦截器注入到容器中
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();// 创建mybatis-plus拦截器
        PaginationInnerInterceptor innerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);// 创建分页拦截器
        innerInterceptor.setOverflow(true);// 设置分页拦截器中页码溢出时是否做友好处理（即显示第一页）
        interceptor.addInnerInterceptor(innerInterceptor);// 将子拦截器加入到mybatis-plus总拦截器
        return interceptor;
    }

}
